#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "scorekeeperscreen.h"
#include "vieweditscreen.h"
#include <QCoreApplication>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent), ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Useing signals and slots to connect buttons to the specified screen
    connect(ui->playButton,SIGNAL(clicked()),this,SLOT(openScoreKeeperWindow()));
    connect(ui->createButton,SIGNAL(clicked()),this,SLOT(openCreateWindow()));
    connect(ui->viewEditButton,SIGNAL(clicked()),this,SLOT(openViewEditWindow()));
}

MainWindow::~MainWindow()
{
    delete ui;
}
// Open the window screens
void MainWindow::openViewEditWindow()
{
    myNewWindow3 = new ViewEditScreen();
    myNewWindow3->show();
}

void MainWindow::viewEditButtonClicked()
{
    openViewEditWindow();
}
void MainWindow::openCreateWindow()
{
    myNewWindow2 = new CreatePlayerScreen();
    myNewWindow2->show();
}

void MainWindow::createButtonClicked()
{
    openCreateWindow();
}

void MainWindow::openScoreKeeperWindow()
{
    myNewWindow = new ScoreKeeperScreen();
    myNewWindow->show();
}

void MainWindow::playButtonClicked()
{
    openScoreKeeperWindow();
}



void MainWindow::setOrientation(ScreenOrientation orientation)
{
    Qt::WidgetAttribute attribute;
    switch (orientation) {
#if QT_VERSION < 0x040702
    // Qt < 4.7.2 does not yet have the Qt::WA_*Orientation attributes
    case ScreenOrientationLockPortrait:
        attribute = static_cast<Qt::WidgetAttribute>(128);
        break;
    case ScreenOrientationLockLandscape:
        attribute = static_cast<Qt::WidgetAttribute>(129);
        break;
    default:
    case ScreenOrientationAuto:
        attribute = static_cast<Qt::WidgetAttribute>(130);
        break;
#else // QT_VERSION < 0x040702
    case ScreenOrientationLockPortrait:
        attribute = Qt::WA_LockPortraitOrientation;
        break;
    case ScreenOrientationLockLandscape:
        attribute = Qt::WA_LockLandscapeOrientation;
        break;
    default:
    case ScreenOrientationAuto:
        attribute = Qt::WA_AutoOrientation;
        break;
#endif // QT_VERSION < 0x040702
    };
    setAttribute(attribute, true);
}

void MainWindow::showExpanded()
{
#if defined(Q_WS_SIMULATOR)
    showFullScreen();
#elif defined(Q_WS_MAEMO_5)
    showMaximized();
#else
    show();
#endif
}

